get value of checked[ALL] or unchecked box jquery
Posted
by python
on Stack Overflow
See other posts from Stack Overflow
or by python
Published on 2010-04-01T08:33:43Z
Indexed on
2010/04/01
8:43 UTC
Read the original article
Hit count: 383
jQuery
I have read this.
http://stackoverflow.com/questions/2048485/jquery-checkbox
<input type="checkbox" name="checkGroup" id="all">
<input type="checkbox" name="checkGroup" id="one" value="1">
<input type="checkbox" name="checkGroup" id="two" value="2">
<input type="checkbox" name="checkGroup" id="three" value="3">
<input type="hidden" name="storeCheck" value="">
$(function(){
$("#all").click(function(){
$("input:checkbox[name='checkGroup']").attr("checked",$(this).attr("checked"));
});
$("input:checkbox[name='checkGroup']:not('#all')").click ( function(){
var totalCheckboxes = $("input:checkbox[name='checkGroup']:not('#all')").length;
var checkedCheckboxes = $("input:checkbox[name='checkGroup']:not('#all'):checked").length;
if ( totalCheckboxes === checkedCheckboxes )
{
$("#all").attr("checked" , true );
}
else
{
$("#all").attr("checked" , false );
}
});
});
I am trying to get the value of the checkboxs are checked as an array.
for example
if I checked All
Get value array_check = 1,2,3 and passed this array to hidden name="storeCheck"
otherwise:
Get value of array_check( checkboxs checked ).and passed this array to hidden name="storeCheck"
© Stack Overflow or respective owner